﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Orders.aspx.cs" Inherits="Orders" Trace="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .blockUI.blockOverlay
        {
            z-index: 1000;
            border: medium none;
            margin: 0px;
            padding: 0px;
            width: 100%;
            height: 100%;
            top: 0px;
            left: 0px;
            background-color: rgb(0, 0, 0);
            opacity: 0.6;
            cursor: wait;
            position: fixed;
        }
        .blockUI.blockMsg.blockPage
        {
            z-index: 1001;
            position: fixed;
            padding: 0px;
            margin: 0px;
            width: 30%;
            top: 40%;
            left: 35%;
            text-align: center; /*color: rgb(0, 0, 0);*/
            border: 3px solid rgb(170, 170, 170);
            background-color: rgb(255, 255, 255);
            cursor: wait;
            color: Red;
            font-weight: bolder;
        }
    </style>
    <script type="text/javascript">
        function BlockUI(elementID) {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_beginRequest(function () {
                $("#" + elementID).block({ message: '<table align = "center" class="StatusBar"><tr><td>' +
     '<img src="loadingAnim.gif"/></td></tr></table>',
                    css: {},
                    overlayCSS: { backgroundColor: '#000000', opacity: 0.6, border: '3px solid #63B2EB'
                    }
                });
            });

            prm.add_endRequest(function () {
                $("#" + elementID).unblock();
            });
        }

        $(document).ready(function () {
            BlockUI("dvGrid1");
            BlockUI("dvGrid2");
            $.blockUI.defaults.css = {};
        });

    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager runat="server" />
    <h1 id="itemListTitle" runat="server" style="text-align: center; text-decoration: underline;
        text-transform: capitalize; font-size: xx-large; font-weight: bolder; margin-bottom: 25px;">
        Current orders details:</h1>
    <table style="width: 100%;">
        <tr>
            <td>
                <asp:Label ID="lblAvailableOrders" Text="Available Orders:" runat="server" />
            </td>
            <td style="text-align: left; width: 50%">
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <asp:Label ID="lblProductsInOrder" Text="Products within order:" runat="server" />
                        <asp:Label ID="lblMessage" Text="" Visible="false" runat="server" Style="color: Red;
                            font-weight: bold; font-size: smaller;" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td style="vertical-align: top;">
                <asp:Label Visible="false" runat="server" ID="SelectedPage" Text="" EnableViewState="true"
                    ViewStateMode="Enabled" />
                <asp:Label Visible="false" runat="server" ID="SelectedIndex" Text="" EnableViewState="true"
                    ViewStateMode="Enabled" />
                <asp:Label Visible="false" runat="server" ID="SelectedOrderID" Text="" EnableViewState="true"
                    ViewStateMode="Enabled" />
                <div id="dvGrid1" style="padding-top: 10px; padding-bottom: 10px; width: 100%">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:GridView runat="server" ID="gvOrders" AllowPaging="True" PageSize="6" AutoGenerateColumns="False"
                                BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
                                CellPadding="4" CellSpacing="2" ForeColor="Black" OnSelectedIndexChanged="gvOrders_SelectedIndexChanged"
                                OnPageIndexChanging="gvOrders_PageIndexChanging">
                                <Columns>
                                    <asp:BoundField HeaderText="ID" DataField="id" />
                                    <asp:BoundField HeaderText="Date" DataField="date" />
                                    <asp:BoundField HeaderText="Receive date" DataField="recievedate" />
                                    <asp:BoundField HeaderText="Dept. ID" DataField="departmentid" />
                                    <asp:CommandField ButtonType="Button" ShowSelectButton="True" SelectText="Details" />
                                </Columns>
                                <FooterStyle BackColor="#CCCCCC" />
                                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" />
                                <SelectedRowStyle BackColor="#000099" Font-Bold="false" ForeColor="White" />
                                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                <SortedAscendingHeaderStyle BackColor="Gray" />
                                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                <SortedDescendingHeaderStyle BackColor="#383838" />
                                <EmptyDataTemplate>
                                    <table style="width: 100%;">
                                        <tbody>
                                            <tr>
                                                <td style="vertical-align: top;">
                                                    <div id="dvGrid1" style="width: 100%">
                                                        <div id="MainContent_UpdatePanel1">
                                                            <div>
                                                                <table cellspacing="2" cellpadding="4" rules="all" id="MainContent_gvOrders" style="color: Black;
                                                                    background-color: #CCCCCC; border-color: #999999; border-width: 3px; border-style: Solid;">
                                                                    <tbody>
                                                                        <tr style="color: White; background-color: Black; font-weight: bold;">
                                                                            <th scope="col" style="width: 14px;">
                                                                                ID
                                                                            </th>
                                                                            <th scope="col" style="width: 125px;">
                                                                                Date
                                                                            </th>
                                                                            <th scope="col" style="width: 125px;">
                                                                                Receive date
                                                                            </th>
                                                                            <th scope="col" style="width: 52px;">
                                                                                Dept. ID
                                                                            </th>
                                                                            <th scope="col" style="width: 58px;">
                                                                                &nbsp;
                                                                            </th>
                                                                        </tr>
                                                                        <tr>
                                                                            <td colspan="5">
                                                                                <asp:Label ID="lblNoOrders" Text="There are no orders to be shown." Style="color: Red;
                                                                                    font-weight: bold;" runat="server" />
                                                                            </td>
                                                                        </tr>
                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </EmptyDataTemplate>
                            </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="gvOrders" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </td>
            <td style="vertical-align: top;">
                <div id="dvGrid2" style="padding-top: 10px; padding-bottom: 10px; width: 100%">
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:Label ID="lblHelp" Style="color: Red; font-weight: bold;" runat="server">Choose order details for products to be shown!</asp:Label>
                            <asp:GridView runat="server" ID="gvOrderedProducts" AllowPaging="True" PageSize="6"
                                AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
                                BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" OnRowEditing="gvOrderedProducts_RowEditing"
                                OnRowCancelingEdit="gvOrderedProducts_RowCancelingEdit" OnRowDataBound="gvOrderedProducts_RowDataBound"
                                OnRowUpdating="gvOrderedProducts_RowUpdating" RowStyle-Height="35px" ShowHeader="true"
                                ShowHeaderWhenEmpty="true">
                                <Columns>
                                    <asp:BoundField HeaderText="ID" DataField="id" ReadOnly="true" />
                                    <asp:BoundField HeaderText="Amount" DataField="amount" ReadOnly="true" />
                                    <asp:TemplateField HeaderText="Product code">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProductCode" Text='<%# (Eval("productcode")) %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Order ID">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOrderID" Text='<%# (Eval("order")) %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status" runat="server">
                                        <EditItemTemplate runat="server">
                                            <asp:DropDownList runat="server" ID="ddlProductStatus" Style="font-size: 10px;">
                                            </asp:DropDownList>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblProductStatus" runat="server" Text='<%# (Eval("orderstatus")) %>'
                                                Width="110px" Style="text-align: center" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField ShowEditButton="True" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Center" />
                                </Columns>
                                <FooterStyle BackColor="#CCCCCC" />
                                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" />
                                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                <SortedAscendingHeaderStyle BackColor="Gray" />
                                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                <SortedDescendingHeaderStyle BackColor="#383838" />
                                <EmptyDataTemplate>
                                    <asp:Label Text="There are no products in this order. (Probably fatal error)" runat="server" />
                                </EmptyDataTemplate>
                            </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="gvOrderedProducts" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
